# !/usr/bin/env python3
# -*- coding:utf-8 -*-
# author: 廖择贵
# createTime: 
# action: 执行测试

import unittest
import os
import time
from config.setting import config
from libs.HTMLTestRunnerNew import HTMLTestRunner


if __name__ == "__main__":
    # 初始化
    testLoader = unittest.TestLoader()
    # 加载测试用例到集合中
    suite = testLoader.discover(config.test_path, pattern='test_*.py')

    # 格式化当前日期
    running_time = time.strftime('%Y%m%d%H%M%S', time.localtime(time.time()))
    # 指定运行结果保存的文件路径
    file_path = os.path.join(config.report_path, 'test_result_{}.html'.format(running_time))
    # 运行测试
    with open(file_path, 'wb') as f:
        # 初始化运行器，生成测试报告
        runner = HTMLTestRunner(stream=f, title="接口自动化测试报告", description=u"第1个报告", tester='lzg', verbosity=2)
        # 运行测试用例
        runner.run(suite)









